#!/usr/bin/perl -w
if($#ARGV!=2){
    die "syntax: a1 a2 f\n";
}

($a1,$a2,$w10)=@ARGV;
$it=0;
$d=$a1-$a2;
$s=$a1+$a2;
$w1=$w10;
$w2=1-$w10;
$filename="../maxW-a1_$a1-"."a2_$a2"."f$w10".".dat";
open(IN,"$filename");
while(<IN>){
    chomp;
    @tabl=split /\s+/;
    $b=$tabl[$#tabl];
    $avgw=($w1+$w2)*0.5;
    $oldw1=$w1;
    $oldw2=$w2;
    $z=$b/$d;
    $z2=$z*$z;
    $sqrt1pz2=sqrt(1+$z2);
    $vpnorminv=1/sqrt($z2+(-1+$sqrt1pz2)*(-1+$sqrt1pz2));
    $v1p=$z;
    $v2p=(-1+$sqrt1pz2);
    $omegap=($w10*$v1p+(1-$w10)*$v2p)*$vpnorminv; #projection of the initial condition on v^\pm
    $w1=(1+$a1)*$oldw1+$b*($avgw-$w1);
    $w2=(1+$a2)*$oldw2+$b*($avgw-$w2);
    $totw=$w1+$w2;
    $ratio=$w1/$w2;    
    $it++;
    print  "$it $totw $ratio $w1 $w2 $b\n";
}
